import 'package:get_it/get_it.dart';
import 'package:website.core/injection_container.dart' as core_di;
import 'package:website.home/signing_in_page/domain/helpers/validate_signing_in_password/validate_signing_in_password.dart';
import 'package:website.home/signing_in_page/domain/use_cases/sign_in/use_case.dart';
import 'package:website.home/signing_up_page/domain/use_cases/sign_up/use_case.dart';
import 'package:website.home/signing_up_page/domain/use_cases/verify_email_during_signing_up/use_case.dart';
import 'package:website.home/web_purchase_item_page/domain/use_cases/get_web_purchase_item_models/use_case.dart';
import 'package:website.home/web_purchase_item_page/domain/use_cases/place_order/use_case.dart';
import 'package:website.home.account/injection_container.dart' as account_di;

final sl = GetIt.asNewInstance();

Future<void> init() async {
  await account_di.init();

  /////////////////////////////////////////////////////////////////////////////////////////////////
  // signing in page
  /////////////////////////////////////////////////////////////////////////////////////////////////

  // use cases

  sl.registerLazySingleton<SignIn>(() {
    return SignInImpl(
      authRepository: core_di.sl(),
      userLocalRepository: core_di.sl(),
      updateAccessCredentials: core_di.sl(),
    );
  });

  // domain helpers

  sl.registerLazySingleton<ValidateSigningInPassword>(() {
    return const ValidateSigningInPasswordImpl();
  });

  /////////////////////////////////////////////////////////////////////////////////////////////////
  // signing up page
  /////////////////////////////////////////////////////////////////////////////////////////////////

  // use cases

  sl.registerLazySingleton<VerifyEmailDuringSigningUp>(() {
    return VerifyEmailDuringSigningUpImpl(
      authRepository: core_di.sl(),
    );
  });

  sl.registerLazySingleton<SignUp>(() {
    return SignUpImpl(
      authRepository: core_di.sl(),
      userLocalRepository: core_di.sl(),
      updateAccessCredentials: core_di.sl(),
    );
  });

  /////////////////////////////////////////////////////////////////////////////////////////////////
  // web purchase item page
  /////////////////////////////////////////////////////////////////////////////////////////////////

  // use cases

  sl.registerLazySingleton<GetWebPurchaseItemModels>(() {
    return GetWebPurchaseItemModelsImpl(
      purchaseItemRepository: core_di.sl(),
      addSpacesToPrice: core_di.sl(),
      prettifyWebPurchaseItemPrices: core_di.sl(),
    );
  });

  sl.registerLazySingleton<PlaceOrder>(() {
    return PlaceOrderImpl(
      purchaseRepository: core_di.sl(),
    );
  });
}
